﻿<UserControl x:Class="CDC.SampleShell.Presentation.Content.DataTab"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:controls="clr-namespace:CDC.SampleShell.Presentation.Controls"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid Background="White">
        

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Border Grid.Row="0" Background="Transparent" BorderBrush="Silver" BorderThickness="0, 0, 0, 1" >
            <Grid Margin="10, 10, 10, 10" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <StackPanel Grid.Column="0" HorizontalAlignment="Left">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="SHOW" />
                        <StackPanel Width="10" />
                        <ComboBox Width="120" BorderBrush="{StaticResource ThemeLightBrush}" SelectedIndex="0">
                            <ComboBoxItem>All</ComboBoxItem>
                        </ComboBox>
                    </StackPanel>
                </StackPanel>

                <StackPanel Grid.Column="1" HorizontalAlignment="Left" Margin="30, 0, 0, 0">
                    <CheckBox Content="Show deleted records" />
                </StackPanel>

                <StackPanel Grid.Column="2" HorizontalAlignment="Right">

                    <!--<Grid>
                            <TextBox Width="200" BorderBrush="{StaticResource ResourceKey=ThemeLightBrush}" />
                            <TextBlock FontStyle="Italic" Foreground="Silver" Text="Search" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10, 0, 0, 0" />
                        </Grid>-->
                    <controls:SearchBox Text="{Binding SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    <StackPanel Height="10" />

                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                        <Button Width="Auto"
                                    HorizontalAlignment="Right"
                                    Command="{Binding AddRecordCommand}"
                                    Content="Add Record" Margin="0, 0, 10, 0" />

                        <Button Width="Auto"
                                    HorizontalAlignment="Right"
                                    Command="{Binding PrintRecordsCommand}"
                                    Content="Print List" />
                    </StackPanel>

                </StackPanel>
            </Grid>
        </Border>
        <DataGrid x:Name="dgMain" 
                      Margin="0, 2, 0, 0"
                  Grid.Row="1" 
                      VirtualizingPanel.IsVirtualizing="True"
                      VirtualizingPanel.VirtualizationMode="Recycling"
                  ItemsSource="{Binding RecordCollectionView}" 
                  AutoGenerateColumns="False" 
                  IsReadOnly="False"
                      IsSynchronizedWithCurrentItem="True"
                  Visibility="{Binding ViewShowing, Converter={StaticResource TabDisplayConverter}, ConverterParameter='Records'}">
            <DataGrid.Columns>

                <!--DataGridTemplateColumn Header="" Width="Auto">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Background="Transparent">
                                <Path Width="12" 
                                          Height="12" 
                                          Stretch="Fill" 
                                          Visibility="{Binding IsLocked, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}"
                                        Data="F1 M 22.17,36.4216L 25.3369,36.4216L 25.3369,31.6711C 25.3369,24.6745 31.0087,19.0027 38.0053,19.0027C 45.0019,19.0027 50.6737,24.6745 50.6737,31.6711L 50.6737,36.4216L 53.841,36.4216L 53.8411,57.008L 22.17,57.008L 22.17,36.4216 Z M 45.9231,31.6711C 45.9231,27.2982 42.3782,23.7533 38.0053,23.7533C 33.6324,23.7533 30.0875,27.2982 30.0875,31.6711L 30.0875,36.4216L 45.923,36.4216L 45.9231,31.6711 Z">
                                    <Path.Style>
                                        <Style TargetType="{x:Type Path}">
                                            <Setter Property="Fill" Value="{StaticResource ThemeBrush}" />
                                            <Style.Triggers>
                                                <DataTrigger
                                                                Binding="{Binding
                                                                    RelativeSource={RelativeSource
                                                                        Mode=FindAncestor,
                                                                        AncestorType={x:Type DataGridCell}},
                                                                        Path=IsSelected}"
                                                                Value="True">
                                                    <Setter Property="Fill" Value="White"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Path.Style>
                                </Path>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>-->
                
                <DataGridTemplateColumn Header="">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>

                            <CheckBox IsChecked="{Binding IsSelectedForDeletion, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTextColumn Header="Case ID" IsReadOnly="True" Binding="{Binding ID}" />
                <DataGridTextColumn Header="Last name" Binding="{Binding LASTNAME}" />
                <DataGridTextColumn Header="First name" Binding="{Binding FIRST}" />
                <DataGridTextColumn Header="Sex" Binding="{Binding SEX}" />
                <DataGridTextColumn Header="Age" Binding="{Binding AGE}" />
                <DataGridTextColumn Header="Address" Binding="{Binding ADDRESS}" />
                <DataGridTextColumn Header="City" Binding="{Binding CITY}" />
                <DataGridTextColumn Header="County" Binding="{Binding COUNTY}" />
                <DataGridTextColumn Header="Event code" Binding="{Binding EVENT}" />
                <DataGridTextColumn Header="Event date" Binding="{Binding EVENTDATE, StringFormat='d'}" />
                <DataGridTextColumn Header="MMWR week" Binding="{Binding MMWRWK}" />
            </DataGrid.Columns>
        </DataGrid>
        <Border Grid.Row="2" Background="#F0F0F0" Padding="10" BorderThickness="0, 2, 0, 0" BorderBrush="Silver">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Grid Grid.Row="0" Margin="0, 0, 0, 10">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    
                    <StackPanel Orientation="Horizontal" DataContext="{Binding RecordCollectionView.CurrentItem}" >

                        <Path Width="14" VerticalAlignment="Center"
                                          Height="14" 
                                          Stretch="Fill" 
                              Visibility="{Binding IsLocked, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}"
                              Margin="0, 0, 10, 0"
                              Fill="{StaticResource ThemeBrush}"
                                          
                                        Data="F1 M 22.17,36.4216L 25.3369,36.4216L 25.3369,31.6711C 25.3369,24.6745 31.0087,19.0027 38.0053,19.0027C 45.0019,19.0027 50.6737,24.6745 50.6737,31.6711L 50.6737,36.4216L 53.841,36.4216L 53.8411,57.008L 22.17,57.008L 22.17,36.4216 Z M 45.9231,31.6711C 45.9231,27.2982 42.3782,23.7533 38.0053,23.7533C 33.6324,23.7533 30.0875,27.2982 30.0875,31.6711L 30.0875,36.4216L 45.923,36.4216L 45.9231,31.6711 Z"/>
                        
                        <TextBlock FontSize="18" VerticalAlignment="Center" FontWeight="Bold" Foreground="{StaticResource ResourceKey=ThemeLightBrush}" Text="{Binding FIRST}" />
                        <TextBlock FontSize="18" VerticalAlignment="Center" Margin="8, 0, 0, 0" FontWeight="Bold" Foreground="{StaticResource ResourceKey=ThemeLightBrush}" Text="{Binding LASTNAME}" />
                    </StackPanel>
                    
                    <Expander Grid.Column="1" x:Name="infoExpander" IsExpanded="True">
                    </Expander>
                </Grid>

                <StackPanel Grid.Row="1" DataContext="{Binding RecordCollectionView.CurrentItem}" Visibility="{Binding ElementName=infoExpander, Path=IsExpanded, Converter={StaticResource BooleanToVisibilityConverter}}" >
                    <StackPanel Orientation="Horizontal">
                        <!-- overview -->
                        <StackPanel>
                            <TextBlock FontWeight="Bold">OVERVIEW</TextBlock>
                            <StackPanel Height="5" />

                            <Grid Margin="0, 5, 30, 5">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="10" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <TextBlock Grid.Row="0" Text="Event date:" />
                                <TextBlock Grid.Row="1" Text="County:" />
                                <TextBlock Grid.Row="2" Text="City:" />
                                <TextBlock Grid.Row="3" Text="Disease:" />

                                <TextBlock Grid.Column="2" Grid.Row="0" Text="{Binding EVENTDATE, StringFormat='d'}" />
                                <TextBlock Grid.Column="2" Grid.Row="1" Text="{Binding COUNTY}" />
                                <TextBlock Grid.Column="2" Grid.Row="2" Text="{Binding CITY}" />
                                <TextBlock Grid.Column="2" Grid.Row="3" Text="{Binding DISEASE}" />
                            </Grid>
                        </StackPanel>

                        <!-- contacts -->
                        <!--<StackPanel>
                                <TextBlock FontWeight="Bold">CONTACTS</TextBlock>
                                <StackPanel Height="5" />

                                <Grid Margin="5, 5, 30, 5">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="10" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <TextBlock Grid.Row="0" Text="Total contacts:" />
                                    <TextBlock Grid.Row="1" Text="Contacts in follow-up:" />
                                    <TextBlock Grid.Row="2" Text="Contacts converted to cases:" />
                                    <TextBlock Grid.Row="3" Text="Contacts discharged:" />

                                    <TextBlock Grid.Column="2" Grid.Row="0" Text="15" />
                                    <TextBlock Grid.Column="2" Grid.Row="1" Text="5" />
                                    <TextBlock Grid.Column="2" Grid.Row="2" Text="0" />
                                    <TextBlock Grid.Column="2" Grid.Row="3" Text="10" />
                                </Grid>
                            </StackPanel>-->


                    </StackPanel>

                </StackPanel>

                <StackPanel Grid.Row="2" HorizontalAlignment="Right" Orientation="Horizontal">
                    <Button Command="{Binding EditRecordCommand}" DataContext="{Binding RecordCollectionView.CurrentItem}"
                            Content="Edit"  />

                    <StackPanel Width="10" />

                    <Button Command="{Binding DeleteRecordCommand}" DataContext="{Binding RecordCollectionView.CurrentItem}"
                            Content="Delete"  />

                    <StackPanel Width="10" />

                    <Button Command="{Binding DeleteRecordsCommand}"
                            Content="Delete Selected"  />
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</UserControl>
